package com.beiing.tianshuai.tianshuai.mine.presenter;

import com.beiing.tianshuai.tianshuai.base.BasePresenter;
import com.beiing.tianshuai.tianshuai.entity.CommonBean;
import com.beiing.tianshuai.tianshuai.mine.model.ForgetPasswordModel;
import com.beiing.tianshuai.tianshuai.mine.model.ForgetPasswordModelImpl;
import com.beiing.tianshuai.tianshuai.mine.view.ForgetPasswordViewImpl;

/**
 * Created by Jinni on 2017/8/7 0007.
 */

public class ForgetPasswordPresenter extends BasePresenter implements ForgetPasswordPresenterImpl, ForgetPasswordModel.OnRequestListener {

    private ForgetPasswordModelImpl mModel;
    private ForgetPasswordViewImpl mView;

    public ForgetPasswordPresenter(ForgetPasswordViewImpl view) {
        mView = view;
        mModel = new ForgetPasswordModel(this);
    }

    @Override
    public void getEditPasswordResult(String email, String pass, String safeCode) {
        mView.showProgress();
        mModel.getEditPasswordResult(email, pass, safeCode);
    }

    @Override
    public void getSafeCodeResult(String email) {
        mView.showProgress();
        mModel.getSafeCodeResult(email);
    }

    @Override
    public void onEditSuccess(CommonBean bean) {
        mView.hideProgress();
        mView.onRequestSuccess(bean);
    }

    @Override
    public void onGetSafeCodeSuccess(CommonBean bean) {
        mView.hideProgress();
        mView.getSafeCodeResult(bean);
    }

    @Override
    public void onError(Throwable e) {
        mView.hideProgress();
        mView.onRequestFailed(e);
    }
}
